package com.supermap.dataservice.cloud.warnInfo;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.mysql.config.DynamicDataSourceContextHolder;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.cloud.warnInfo.WarnInfo;
import com.supermap.dubbo.api.cloud.warnInfo.WarningInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author aqua
 * @description
 * @date 2018年12月03 下午 4:50
 * @email 1301584033@qq.com
 */
@Service
public class WarningInfoServiceImpl implements WarningInfoService {

    @Resource
    private WarningInfoMapper warningInfoMapper;
    @Override
    public void insertWarnInfoList(List<WarnInfo> warnInfoList) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        warningInfoMapper.insertWarnInfoList(warnInfoList);
    }

    @Override
    public JSONUtil getWarnInfoById(Integer warnInfoId) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(warningInfoMapper.getWarnInfoById(warnInfoId));
    }

    @Override
    public JSONUtil getPageWarnInfoByTimeOrareaCode(String areaCode, String beginTime, String endTime, int pageNum, int pageSize) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds2");
        return new JSONUtil().setData(warningInfoMapper.
                getPageWarnInfoByTimeOrAreaCode(areaCode,beginTime,endTime,pageNum,pageSize))
                .setCountSum(warningInfoMapper.getPageWarnInfoByTimeOrAreaCodeCountNum(areaCode,beginTime,endTime,pageNum,pageSize));
    }


}
